﻿/*
Copyright (C) 2007 Kamal Singh.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/


quote_url = "http://www.bloomberg.com/apps/quote?ticker=";
wmp = WMPEmbed.object;

function view_onOpen() {
	view.setInterval(displayStatus, 1000);
}

function displayStatus() {
	run_time.innerText = wmp.controls.currentPositionString;
	status.innerText = wmp.status;
}

function volume_onchange() {
  if( wmp == null ) return;
  wmp.settings.volume = volumeController.value;
}

function stop_onclick() {
	wmp.controls.stop();
	play_control.visible = true;
	pause_control.visible = false;}

function play_onclick() {
	wmp.controls.play();
	play_control.visible = false;
	pause_control.visible = true;
}

function quote_input_onfocusin() {
	quote_input.value = "";
}

function quote_input_onfocusout() {
	quote_input.value = "Enter Symbol";
}

function quote_onclick() {
	var symbol = quote_input.value;
	if ( symbol != null && symbol != '' )
	  openURL( quote_url + symbol );

	quote_input_onfocusout();
}

// Opens the requested URL using the user's default web browser
function openURL( url ) {
  try {
    var shell = new ActiveXObject( "Shell.Application" );
    shell.Open( url );
  }
	catch ( e ) {
    return;
	}
}

function onTextBoxKeyPress() {
  // Clear the search box if the escape key is pressed
  if (event.keyCode == 27) {
    quote_input.value = "";
    return;
  }

  // When the enter key is pressed, the action depends on if this gadget is
  // currently in the sidebar or floating.
  if (event.keyCode == 13)
		quote_onclick();
}